package edu.caltech.android.eew;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class UserPositionOverlay extends Overlay {
	private static final String TAG = "UserPositionOverlay";

	private GeoPoint mPosition;
	private Context mContext;
	private Point positionPoint = new Point();
	private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

	public UserPositionOverlay(GeoPoint position, Context context) {
		mPosition = position;
		mContext = context;
	}
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

	     // Transfrom geoposition to Point on canvas
	     Projection projection = mapView.getProjection();
	     projection.toPixels(mPosition, positionPoint);

	     // the circle to mark the spot
	     //circle.setColor(Color.parseColor("#88ff0000"));
	     paint.setColor(Color.RED);
	     paint.setAlpha(255); 

	     // TODO: choose this more carefully.
	     int radiusInPixels = 10;
	     canvas.drawCircle(positionPoint.x, positionPoint.y, radiusInPixels, paint);       

	}
}
